<?php
/**
 * Created by PhpStorm.
 * User: alinejun
 * Date: 2019/3/18
 * Time: 23:28
 */
namespace app\common\model;

/**
 * 配置模型
 */
class City extends ModelBase
{

    public function getName($cate_id)
    {
        return $this->field('name')->find($cate_id)['name'];
    }

    public function getAllName($city_id)
    {
        $city_info = $this->field('name,pid')->find($city_id);
        $name[] =  $city_info['name'];

        $pid = $city_info['pid'];
        while($pid){
            $info = $this->field('name,pid')->find($pid);
            $name[] = $info['name'];
            $pid = $info['pid'];
        }
        $name = array_reverse($name,true);

        return implode('/',$name);
    }
}
